import http from '@src/util/HttpUtil';
const fixedPrefixTaskPath = '/api/task';
export const taskPath = fixedPrefixTaskPath
/* ------------- start 附加组件设置 ---------------- */
/**
 * @description 获取附加组件列表
 * @param {Object} params -- 参数对象
 * @param {String} params.id -- 组件id
 */
export const getAllCardList = (params = {} ) => {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/task/getAllCardList`, params)
}

/**
 * @description 通过组件id获取附加组件信息
 * @param {Object} params -- 参数对象
 * @param {String} params.id -- 组件id
 */
export const getCardInfo = (params = {} ) => {
  return http.get('/setting/task/card/getOne', params)
}
/**
 * @description 添加为单次/多次
 * @param {Object} params -- 参数对象
 * @param {String} params.cardId -- 组件id
 * @param {String} params.inputType -- single单次 multiple多次
 */
export const cardImport = (params = {}) => {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/inventory/initInventoryConfig`, params)
}

/**
 * @description 开启禁用工单附加组件
 * @param {Object} params -- 参数对象
 * @param {String} params.id -- 组件id
 * @param {String} params.enabled -- 1开启 0禁用
 */
export const onCardChange = (params = {}) => {
  return http.post('/setting/task/card/enabled', params, false)
}

/**
 * @description 删除附加组件
 * @param {Object} params -- 参数对象
 * @param {String} params.id -- 组件id
 */
export const onDeleteCard = (params = {}) => {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/inventory/deleteBaseTaskCard`, params)
}

/**
 * @description 创建附加组件
 * @param {Object} params -- 参数对象
 * @param {String} params.description -- 组件说明
 * @param {String} params.inputType -- single单次 multiple多次
 * @param {String} params.name -- 组件名字
 */
export const onCreatCard = (params = {}) => {
  return http.post('/setting/task/card/create', params)
}

/**
 * @description 更新附加组件
 * @param {Object} params -- 参数对象
 * @param {String} params.description -- 组件说明
 * @param {String} params.id -- 组件id
 * @param {String} params.name -- 组件名字
 */
export const onUpdateCard = (params = {}) => {
  return http.post('/setting/task/card/update', params)
}


/**
 * @description 获取统计列表
 * @param {Object} params -- 参数对象
 * @param {String} params.cardId -- 组件id
 * @param {String} params.pageNum -- 第几页
 * @param {String} params.pageSize -- 每页展示多少条
 * @param {String} params.timeRange -- 时间范围
 * @param {String} params.userNameStr -- 操作人
 */
export const getCardCount = (params = {}) => {
  return http.post('/setting/task/newCard/count', params)
}

/**
 * @description 获取统计fields列表
 * @param {Object} params -- 参数对象
 */
export const getCardFields = (params = {}) => {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/inventory/getInventoryField`, params)
}

/**
 * @description 附加组件库
 * @param {Object} 
 */
export const getCardSysList = (params = {}) => {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/setting/card/getSysList`, params)
}

/**
 * @description 获取附加组件表单
 * @param {Object} 
 */
export const getAddCardFields = (params = {}) => {
  return http.get('/setting/task/cardField/new/list', params)
}

/**
 * @description 创建取附加组件表单
 * @param {Object} 
 */
export const taskCardFieldsSave = (params = {}) => {
  return http.post('/setting/task/cardField/createBatch', params)
}

/**
 * @description 删除附加组件
 * @param {Object} 
 */
export const deleteCardField = (params = {}) => {
  return http.post('/setting/task/cardField/delete', params, false)
}

/**
 * @description 附加组件字段唯一性校验
 * @param {Object} 
 */
export const cardFieldRepeat = (params = {}) => {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/task/cardFieldRepeat`, params, false)
}

/**
 * @description 查询单个附加组件的信息
 * @param {Object} 
 */
export const getTaskCardName = (params = {}) => {
  return http.get('/setting/task/card/getOne', params)
}

/**
 * @description 更新单个工单附加组件的信息
 * @param {Object} 
 */
export const updateTaskCardName = (params = {}) => {
  return http.post('/setting/task/card/updateOneTaskCard', params)
}

/**
 * @description 获取工时记录编辑配置详情
 * @param {Object} 
 */
export const getCardConfig = (params = {}) => {
  return http.post('/setting/task/card/getConfig', params, false)
}

/**
 * @description 保存工时记录编辑配置详情
 * @param {Object} 
 */
export const saveCardConfig = (params = {}) => {
  return http.post('/setting/task/card/saveConfig', params)
}

/**
 * @description 获取指定组建的相关配置
 * @param {Object} 
 */
export const getInventoryConfig = (params = {}) => {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/inventory/getInventoryConfig`, params)
}

/**
 * @description 修改组建配置信息
 * @param {Object} 
 */
export const modifyInventoryConfig = (params = {}) => {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/inventory/putInventoryConfig`, params)
}

/**
 * @description 备件、服务清单使用统计接口
 * @param {Object} 
 */
export const statisticalInventory = (params = {}) => {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/inventory/countInventoryByTask`, params)
}

/**
 * @description 获取清单配置字段
 * @param {Object} 
 */
export const getInventoryField = (params = {}) => {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/inventory/getInventoryField`, params)
}


/* ------------- end 附加组件设置 ---------------- */

/* ------------- start 工单类型组件设置 ---------------- */

/**
 * @description 保存排序结果
 * @param {Object} params -- 参数对象
 */
export const saveTaskCardOrder = (params = {}) => {
  return http.post('/setting/saveTaskCardOrder', params)
}

/**
 * @description 删除组件
 * @param {Object} params -- 参数对象
 */
export const deleteTaskCard = (params = {}) => {
  return http.post('/setting/taskType/deleteCard', params, false)
}

/**
 * @description 使用规则设置
 * @param {Object} params -- 参数对象
 */
export const saveRulesFlow = (params = {}) => {
  return http.post('/setting/taskType/card/saveNotNullFlow', params)
}

/**
 * @description 获取角色列表
 * @param {Object} params -- 参数对象
 */
export function getRoleList(params) {
  return http.get('/setting/role/list', params)
}

/**
 * @description 获取角色列表(包含服务商)
 * @param {Object} params -- 参数对象
 */
 export function getUserRoleList(params) {
  return http.get('/user/setting/role/list', params)
}

/**
 * @description 保存角色列表
 * @param {Object} params -- 参数对象
 */
export function saveCardAuth(params) {
  return http.post('/setting/taskType/cardAuth', params, false)
}

/**
 * @description 获取已经使用的组件 
 * @param {Object} params -- 参数对象
 */
export function getEnabledList(params) {
  return http.get('/setting/task/card/getEnabledList', params)
}

/**
 * @description 组件设置页批量保存 
 * @param {Object} params -- 参数对象
 */
export function batchSaveTaskCard(params) {
  return http.post('/setting/taskType/batchSaveTaskCard', params)
}

/**
 * @description 工单类型设置时，获取已配置的服务报告模版列表 
 * @param {Object} params -- 参数对象 taskTypeId
 */
export function getServiceReportListByTaskType(params) {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/task/serviceReport/getListByTaskType`, params)
}

/**
 * @description 获取单个服务报告模版的详情
 * @param {Object} params -- 参数对象 id
 */
export function getServiceReportTemplate(params) {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/task/serviceReport/getServiceReportTemplate`, params)
}

/**
 * @description 获取可配置服务报告模版的工单状态选项值
 * @param {Object} params -- 参数对象
 */
export function getServiceReportTaskStatusOption(params) {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/task/serviceReport/getTaskStatusOption`, params)
}

/**
 * @description 添加单个服务报告模版
 * @param {Object} params -- 参数对象
 */
export function createServiceReportTemplate(params) {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/task/serviceReport/createServiceReportTemplate`, params)
}

/**
 * @description 编辑单个服务报告模版
 * @param {Object} params -- 参数对象
 */
export function editServiceReportTemplate(params) {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/task/serviceReport/editServiceReportTemplate`, params)
}

/**
 * @description 删除单个服务报告模版
 * @param {Object} params -- 参数对象
 */
export function removeServiceReportTemplate(params) {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/task/serviceReport/removeServiceReportTemplate`, params)
}

/**
 * @description 查询智能质检字段
 * @param {Object} params -- 参数对象
 * @param {String} params.taskTypeId -- 工单类型id
 */
export function aiQualityCheckFields(params) {
  return http.get(`${fixedPrefixTaskPath}/outside/pc/task/aiQualityCheckFields`, params)
}

/**
 * @description 添加质检范本图片
 * @param {Object} params -- 参数对象
 */
export function addPicture(params) {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/setting/intelligent/addPicture`, params)
}

/**
 * @description 删除质检范本图片
 * @param {Object} params -- 参数对象
 */
export function deletePicture(params) {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/setting/intelligent/deletePicture`, params)
}

// 保存智能质检的配置
export const getIntelligentConfigSaveApi = ( params = {} ) => {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/setting/taskType/intelligentConfig/save`, params)
}

/**
 * @description 实时质检
 * @param {Object} params -- 参数对象
 */
export function aiCheckQualityBatch(params) {
  return http.post(`${fixedPrefixTaskPath}/outside/pc/task/aiCheckQuality/batch`, params)
}

/**
 * @description 校验实时质检文件
 * @param {Object} params -- 参数对象
 */
export function qualityCheckImage(params) {
  return http.post('/api/app/outside/pc/huaweiImageSearch/checkImage', params)
}

/**
 * @description 设置附加组件权限
 * @param {Object} params -- 参数对象
 */
 export function saveOrUpdateTaskRange(params) {
  return http.post(`${fixedPrefixTaskPath}/outside/task/range/saveOrUpdateTaskRange`, params)
}

/**
 * @description 附加组件权限设置-查询所有权限
 * @param {Object} params -- 参数对象
 * @param {Object} params.objectId -- 查询的附加组件id
 */
 export function getTaskRangeList(params) {
  return http.get(`${fixedPrefixTaskPath}/outside/task/range/getTaskRangeList`, params)
}

/**
 * @description 附加组件权限设置-查询单个权限
 * @param {Object} params -- 参数对象
 * @param {Object} params.objectId -- 查询的附加组件id
 * @param {Object} params.objectType -- 查询某个具体的权限（0：查看 1：新增 2：编辑 3：删除
 */
 export function getTaskRangeDetail(params) {
  return http.get(`${fixedPrefixTaskPath}/outside/task/range/getTaskRangeDetail`, params)
}

/**
 * @description 附加组件权限设置-初始化默认数据接口
 * @param {Object} params -- 参数对象
 * @param {Object} params.taskTypeId -- 工单类型id
 * @param {Object} params.objectIds[] -- 附加组件id1
 */
 export function initDefaultTaskRange(params) {
  return http.post(`${fixedPrefixTaskPath}/outside/task/range/initDefaultTaskRange`, params)
}

/**
 * @description 附加组件权限设置-回显第一级部门和第一级服务商
 * @param {Object} params -- 参数对象
 */
 export function getDefaultTaskRange() {
  return http.get(`${fixedPrefixTaskPath}/outside/task/range/getDefaultTaskRange`)
}
/* ------------- end 工单类型组件设置 ---------------- */


/**
 * @description 获取指定仓库
 * @returns 
 */
export function getWarehouse() {
  return http.get('/api/warehouse/outside/warehouse/list/paas')
}

export function getTaskCardExportFields(params = {}){
	return http.get('/api/task/outside/pc/inventory/getTaskCardExportFields', params);
}


/** 获取工单流程节点接口 */
export function getTaskFlowNode(params) {
	return http.get(`${fixedPrefixTaskPath}/outside/task/flow/node/flowNode`,params);
}

/** 获取租户所有公共节点 */
export function getTaskCommonNode(params) {
	return http.get(`${fixedPrefixTaskPath}/outside/task/flow/node/commonNode`,params);
}
/** 新建自定义节点 */
export function createTaskFlowNode(params) {
	return http.post(`${fixedPrefixTaskPath}/outside/task/flow/node/create`,params);
}
/*
* desc:获取工单类型的状态和按钮-用于附加组件设置规则
* params: taskTypeId工单类型id
*  */
export function getTaskFlowNodeAddons(params) {
    return http.get(`${fixedPrefixTaskPath}/outside/task/flow/node/get/taskFlowInfo`,params);
}
/** 获取当前节点之前的所有节点的表单关联字段 */
export function getCurrentNodeBeforeCommonFields(params) {
	return http.get(`${fixedPrefixTaskPath}/outside/pc/task/getCurrentNodeBeforeCommonFields`,params);
}

/** 添加时校验公共节点 */
export function checkCommonNodeAdd(params) {
	return http.get('/setting/taskType/checkCommonNodeAdd',params);
}
